package com.game.ghost.webapp.apps.data;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.NoSuchElementException;

import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

/**
 * 
 * @author gautak
 *
 */
@Component("wordDictionary")
@Scope(value=BeanDefinition.SCOPE_PROTOTYPE)
public class WordDictionary implements Serializable {

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = -3279708860271587095L;
	
	public static final String CACHE_NAME = "wordDictionary";

	private LinkedList<String> wordList = new LinkedList<String>();
	
	private String word;
	
	public String getWord() {
		return word;
	}

	public void setWord(String word) {
		this.word = word;
	}

	public LinkedList<String> getWordList() {
		return wordList;
	}

	public void setWordList(LinkedList<String> wordList) {
		this.wordList = wordList;
	}

	/**
	 * Return an iterator to the underlying collection of words.
	 */
	public ListIterator<String> listIterator() {
		return wordList.listIterator(0);
	}

	/**
	 * Return the number of words in the dictionary.
	 */
	public long size() {
		return wordList.size();
	}

	/**
	 * Return the first word in the dictionary.
	 */
	public String firstWord() {
		String firstWord = null;

		try {
			firstWord = wordList.getFirst();
		} catch (NoSuchElementException e) {
		}

		return firstWord;
	}


}
